<?php
class userController extends platformController{
	//用户登录的控制器
	public function loginAction(){
		//判断是否有表单提交
		if(!empty($_POST)){
		    $model=new userModel();
		if($model->checkLogin()){
			$this->jump("index.php?p=home&c=news&a=list");			
		}else{
			 echo "<script>alert('登录失败!');</script>";
		}
		//判断用户名
		if(empty($_POST['username'])){
		    echo "<script>alert('登录名不能为空!');</script>";
		    $username=$_POST["username"];
		}else{
			$username=$_POST["username"];
		}
		//判断密码
	    if(empty($_POST['password'])){
		    echo "<script>alert('密码不能为空!');</script>";
		    $password=$_POST["password"];
		}else{
			$password=$_POST["password"];
	    }
	    }
		//载入视图文件
		require CURRENT_VIEW_PATH."user_login.html";
	}
	//退出方法
	public function logoutAction(){
		session_start();
		unset($_SESSION['user']);
		$this->jump("index.php?p=home&c=news&a=list");
	}
}
?>